window.onload = function() {
    let username = document.getElementById("username")
    let password = document.getElementById("password")
    console.log(username.value)

    username.addEventListener("input", (e) => {
        console.log("正在输入", e.target.value)
    })

    let btn = document.querySelector("button")
    btn.addEventListener("click", (e) => {
        e.preventDefault()

        let name = username.value
        let key = password.value

        let xhr = new XMLHttpRequest()
        xhr.open("POST", "http://172.19.14.2:8080/login", true)
        xhr.onreadystatechange = () => {
            if (xhr.readyState === 4 && xhr.status === 200) {
                console.log("POST请求成功了")
                    // location.href = "http://172.18.222.185:8080/login";
                    //这里可以实现页面跳转
            }
        }
        xhr.send()

        let xhr2 = new XMLHttpRequest()
        xhr2.open("GET", "http://172.19.14.2:8080/login" + "?username=" + name + "&key=" + key, true)
        xhr2.onreadystatechange = () => {
            if (xhr2.readyState === 4 && xhr2.status === 200) {
                console.log("GET请求成功了")
                    // location.href = "http://172.18.222.185:8080/login";  
            }
        }
        xhr2.send()
    })
}